load("//tools:defaults.bzl", "esbuild", "http_server", "ts_library")
load("@npm//@angular/build-tooling/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
load("//modules/benchmarks:e2e_test.bzl", "e2e_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])

ts_library(
    name = "ng2_static",
    srcs = glob(["*.ts"]),
    tsconfig = "//modules/benchmarks:tsconfig-build.json",
    deps = [
        "//modules/benchmarks/src:util_lib",
        "//modules/benchmarks/src/tree:util_lib",
        "//packages/compiler",
        "//packages/core",
        "//packages/platform-browser",
        "//packages/platform-browser-dynamic",
    ],
)

# Note: Cannot use `app_bundle` as otherwise the JIT compiler would
# not be available due to side-effects being optimized away.
esbuild(
    name = "app_bundle",
    entry_point = ":index.ts",
    deps = [":ng2_static"],
)

http_server(
    name = "devserver",
    srcs = [
        "index.html",
        "@npm//:node_modules/reflect-metadata/Reflect.js",
    ],
    deps = [
        ":app_bundle",
        "//packages/zone.js/bundles:zone.umd.js",
    ],
)

benchmark_test(
    name = "perf",
    server = ":devserver",
    deps = ["//modules/benchmarks/src/tree:perf_tests_lib"],
)

e2e_test(
    name = "e2e",
    server = ":devserver",
    deps = ["//modules/benchmarks/src/tree:e2e_tests_lib"],
)
